package liudan.archetype.action;

import liudan.archetype.form.ActionForm;
import liudan.archetype.form.LoginForm;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * Description:
 * Title
 * Copyright: Copyright (c) 2017
 * User: liudan
 * Created on 2017/2/17 16:23
 */
public class LoginAction extends Action {
    @Override
    public String execute(ActionForm form, HttpServletRequest request, Map<String, String> forwardMap) {
        LoginForm loginForm = (LoginForm) form;
        if (loginForm.getUsername().equals("admin")) {
            request.setAttribute("message", "<h1>登录成功，欢迎您，" + loginForm.getUsername() + "</h1>");
            return forwardMap.get("success");
        } else {
            request.setAttribute("message", "登录失败");
        }
        return forwardMap.get("faile");
    }
}
